﻿using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplicationPlatformTwo
{
    public partial class frmReportFileView : Form
    {
        public frmReportFileView()
        {
            InitializeComponent();
        }

        private void frmReportFileView_Load(object sender, EventArgs e)
        {

            reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Reports\\ReportTest.rdlc";
            DataTable dt = cratePrintData();
            this.reportViewer1.LocalReport.DataSources.Clear();
            ReportDataSource rds = new ReportDataSource("DataSetTest_DataTableTest", dt);//燃油上传信息数据源
            this.reportViewer1.LocalReport.DataSources.Add(rds);
            this.reportViewer1.RefreshReport();
        }

        private DataTable cratePrintData()
        {
            DataTable rdt = new DataTable();

            rdt.Columns.Add("Id");
            rdt.Columns.Add("Name");

            DataRow inDr = rdt.NewRow();
            inDr["id"] = "1";
            inDr["name"] = "张三";

            rdt.Rows.Add(inDr);

            return rdt;
        }
    }
}
